package com.example.demo.webflux.service;

import com.example.demo.webflux.dao.UserRepository;
import com.example.demo.webflux.entity.UserEntity;
import jakarta.annotation.Resource;
import org.springframework.stereotype.Service;
import reactor.core.publisher.Flux;
import reactor.core.publisher.Mono;

/**
 * @author huangchangjin
 * @date 2025/9/8 17:19
 */
@Service
public class UserService {
    @Resource
    private UserRepository userRepository;

    public Flux<UserEntity> findAll() {
        return userRepository.findAll();
    }

    public Mono<UserEntity> findById(String id) {
        return userRepository.findById(id);
    }

    public Mono<UserEntity> save(UserEntity user) {
        return userRepository.save(user);
    }

    public Mono<Void> deleteById(String id) {
        return userRepository.deleteById(id);
    }
}
